import request from "@/utils/request";
import store from "@/store";
//登录模块的接口
export function login(data){

  return request({
    url: '/app/v1_0/authorizations',
    method: 'post',
    data

  })

}

//发送验证码接口
export function getSmsCode (mobile){

  return request({
    method: 'GET',
    url: `/app/v1_0/sms/codes/${mobile}`
  })
}


/**
 * 获取用户自己的信息
 */
export function getUserInfo (){
  return request({
    method: 'GET',
    url: '/app/v1_0/user',
  })
}

//获取用户的各类文章的频道
export function getArticleList () {
  return request({
    method: 'GET',
    url: '/app/v1_0/user/channels',

  })
}
//获取某个频道的文章
export function getArticles (params) {
  return request({
    method: 'GET',
    url: '/app/v1_1/articles',
    params
  })
}


/**
 * 添加关注
 */
export function addFollow(userId) {
  return request({
    method: 'POST',
    url: '/app/v1_0/user/followings',
    data: {
      target: userId
    }
  })
}

/**
 * 取消关注
 */
export function deleteFollow (userId) {
  return request({
    method: 'DELETE',
    url: `/app/v1_0/user/followings/${userId}`
  })
}
